﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Media;

namespace GUI.Tabs
{
    class ListTextBoxControl:IListBoxControl<TextBox>
    {
        ListBox box { get; set; }
        public ListTextBoxControl(ListBox box)
        {
            this.box = box;
        }


        public void Clear()
        {
            box.Dispatcher.BeginInvoke
            (
                (Action)(() =>
                {
                    box.Items.Clear();
                }
            ));
        }

        public void Add(TextBox text)
        {
            text.Foreground = (text.Text.Equals("Incomplete script line, check all arguments...")) ? Brushes.Red : Brushes.Black;
            box.Dispatcher.BeginInvoke
            (
                (Action)(() =>
                {
                    box.Items.Add(text);
                }
            ));
        }


        public void RemoveAt(int index)
        {
            box.Dispatcher.BeginInvoke
            (
                (Action)(() =>
                {
                    if(index >= 0 && index < box.Items.Count)
                        box.Items.RemoveAt(index);
                }
            ));
        }

        
    }
}
